<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <% include("base/web-settings-meta.html"){} %>
    <title>${site.siteName!}-${data.title!}</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/styles/atom-one-dark.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/css/share.min.css" rel="stylesheet">

</head>


<body>
<% include("base/web-settings-top-nav.html"){} %>
<% include("base/web-settings-reg-login.html"){} %>


<div class="container">

    <div class="row">
        <div class="blog-header"></div>


        <div class="col-sm-9 blog-main">

            <div class="blog-post">

                <header class="kratos-entry-header">
                    <h1 class="kratos-entry-title text-center">${data.title}</h1>
                    <div class="kratos-post-meta text-center">
                    <span>
                    <i class="fa fa-calendar"></i> ${data.createTime!,dateFormat="yyyy-MM-dd HH:mm"}  <i
                            class="fa fa-commenting-o"></i> ${data.reply}条评论                    <i
                            class="fa fa-eye"></i> ${data.views}次阅读
                    <span class="hd">
                    <i class="fa fa-thumbs-o-up"></i> ${data.pros}人点赞 <i class="fa fa-user"></i> ${data.userCname}                    </span>
                    </span>
                    </div>
                </header>

                <div class="kratos-post-content">
                    ${data.content}
                </div>
                <div class="kratos-copyright text-center clearfix">
                    <h5>本作品采用 <a rel="license nofollow" target="_blank"
                                 href="http://creativecommons.org/licenses/by-sa/4.0/">知识共享署名-相同方式共享 4.0 国际许可协议</a> 进行许可
                    </h5>
                </div>


                <footer class="kratos-entry-footer clearfix">
                    <div class="post-like-donate text-center clearfix" id="post-like-donate">
                        <!--
                                                <a href="javascript:;" class="Donate"><i class="fa fa-bitcoin"></i> 打赏</a>
                        -->

                        <a href="javascript:;" id="praise" data-action="love" data-id="3080" class="Love done share-btn"
                           onclick="praise('${data.ename}','${data.shamId}')"><i class="fa fa-thumbs-o-up"></i> 点赞</a>


                        <a href="javascript:;" class="Share share-btn"><i class="fa fa-share-alt"></i> 分享</a>
                        <div class="share-wrap" style="display: none;">
                            <div class="social-share"
                                 data-wechat-qrcode-title="微信扫一扫：分享一下"
                                 data-weibo-title="${data.title}"
                                 data-douban-title="${data.title}"
                                 data-linkedin-title="${data.title}"
                                 data-facebook-title="${data.title}"
                                 data-twitter-title="${data.title}"
                                 data-google-title="${data.title}"
                                 data-disabled="tencent,diandian,qzone"
                                 data-description='${data.intro}'
                                 data-image="${data.imageUrl}"></div>
                        </div>
                    </div>
                    <div class="footer-tag clearfix">
                        <div class="pull-left">
                            <%if(data.topics!=null){%>
                                <i class="fa fa-tags"></i>

                                <%for(topic in data.topics!){%>
                                <a href="/tags/${topic.ename}/tags/${topic.shamId}.html" rel="tag">${topic.name}</a>
                                <%}%>
                            <%}%>
                        </div>

                        <div class="pull-date">
                            <span>最后编辑：${data.lastModifiedTime!,dateFormat="yyyy-MM-dd HH:mm:ss"}</span>
                        </div>
                    </div>
                </footer>


            </div>


            <%if(site.openCmt){%>

            <div class="comments" id="comments">
                <div class="comm-main">
                    <% if(isEmpty(session.authContext)){%>
                    <div>您还没有登录，请先<a data-toggle="modal" data-target="#login" href="#"><i class="fa fa-sign-in"></i> 登录</a>或者<a
                            data-toggle="modal" data-target="#register" href="#"><i class="fa fa-sign-in"></i> 注册</a>后,添加评论
                    </div>
                    <%}else{%>
                    <textarea cols="80" rows="50" placeholder=" 在这里发表你对此文的观点,最多300个字哟~~" class="mytextarea" id="content"
                              maxlength="300"></textarea>

                    <input type="text" class="form-control pull-right index-list-reply-code" name="replyCode" id="replyCode"
                           placeholder="验证码">
                    <img class="pull-right pull-right-verification" id="replyCaptcha"
                         onclick="this.src = '/reply/image?m=' + Math.floor(Math.random() * 10000);"
                         src="/reply/image?m=' + Math.floor(Math.random() * 10000);">
                    <div class="btn btn-success pull-right" id="comment"><i class="fa fa-edit"></i> 发表评论</div>
                    <%}%>
                    <div class="comment-list"></div>
                </div>
            </div>

            <%}%>

        </div><!-- /.blog-main -->

        <div class="col-sm-3  blog-right">
            <% include("base/web-settings-blog-admin-info.html"){} %>
            <% include("base/index-list-blogroll.html"){} %>
            <% include("base/index-list-hot-article.html"){} %>
            <% include("base/index-list-hot-tag.html"){} %>
            <% include("base/index-list-rece-publish.html"){} %>
        </div>


    </div><!-- /.row -->

</div><!-- /.container -->


<% include("base/web-settings-footer.html"){} %>

<% include("base/web-settings-bottom.html"){} %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.12.1/plugins/codesnippet/lib/highlight/highlight.pack.js"></script>
<script src="/js/jquery.comment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/js/social-share.min.js"></script>

<script>
    hljs.initHighlightingOnLoad();

    function praise(ek, id) {
        var kprais = getCookie(ek + "_" + id + "_praise");
        if (kprais) {
            toastr.warning('您已经支持过了');
            return;
        }
        $.ajax({
            cache: false,
            type: "POST",
            contentType: 'application/json',
            url: "/article/rest/" + ek + "/praise/" + id,
            async: false,
            success: function (data) {
                if (data.code === 0) {
                    toastr.success(data.message);
                } else {
                    toastr.warning(data.message);
                }
            },
            error: function (data) {
                toastr.error(data.message);
            }
        });
    }

    function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg)) {
            return unescape(arr[2]);
        } else {
            return null;
        }
    }

    $(document).on("click", ".Share", function () {
        $(".share-wrap").fadeToggle("slow");
    });
</script>

<%if(site.openCmt){%>
<script>


    var im = 'https://data.ijson.net/avatar.jpg';
    //初始化数据
    $(function () {

        var params = {
            index: 1
        };

        $.ajax({
            cache: false,
            type: "POST",
            contentType: 'application/json',
            url: "/reply/${data.ename}/replys/${data.shamId}",
            async: false,
            data: params,
            success: function (data) {
                $(".comment-list").addCommentList({data: data.reply, add: ""});
            },
            error: function (data) {
                toastr.error(data.message);
            }
        });

        /*
        {
            id: 3,
            img: im,
            replyName: "帅大叔",
            beReplyName: "匿名",
            content: "同学聚会，看到当年追我的屌丝开着宝马车带着他老婆来了，他老婆是我隔壁宿舍的同班同学，心里后悔极了。",
            time: "2017-10-17 11:42:53",
            address: "深圳",
            osname: "win10",
            browse: "谷歌",
            replyBody: []
        }
         */

        $("#comment").click(function () {

            var contentValue = $("#content").val();
            var replyCode = $("#replyCode").val();
            if (contentValue == null || contentValue === '' || contentValue === undefined) {
                toastr.error("请输入评论内容");
                return
            }

            if (replyCode == null || replyCode === '' || replyCode === undefined) {
                toastr.error("请输入验证码");
                return
            }

            var obj = {
                img: '${session.authContext.avatar!}',
                postId: '${data.id}',
                replyName: "${session.authContext.cname!}",
                content: contentValue,
                replyBody: [],
                replyCode: replyCode
            };

            $.ajax({
                cache: false,
                type: "POST",
                contentType: 'application/json',
                url: "/reply/${data.ename}/${data.shamId}/save",
                async: false,
                data: JSON.stringify(obj),
                success: function (data) {
                    if (data.code !== undefined && data.code >= 200000013) {
                        toastr.error(data.message);
                    } else {
                        $("#content").val('');
                        $(".comment-list").addCommentList({data: data, add: obj});
                    }

                    $("#replyCode").val('');
                    var replyCaptcha = document.getElementById("replyCaptcha");
                    replyCaptcha.src = '/reply/image?m=' + Math.floor(Math.random() * 10000);

                },
                error: function (data) {
                    toastr.error(data.message);
                }
            });


            //$(".comment-list").addCommentList({data: [], add: obj});
        });
    })
</script>
<%}%>

</body>
</html>
